//
//  GoToManager.m
//  DeyiLife
//
//  Created by zxin on 15/6/26.
//  Copyright (c) 2015年 Deyi. All rights reserved.
//

#import "GoToManager.h"
#import "GoToBase.h"

@interface GoToManager ()

@property (strong, nonatomic) NSDictionary *gotoMap;

@end

@implementation GoToManager

DEFINE_SINGLETON_IMPLEMENTATION(GoToManager)

- (void)go:(id)context type:(NSInteger)type data:(id)data {
    NSString *target = [self.gotoMap objectForKey:@(type)];
    if (target) {
        id object = [[NSClassFromString(target) alloc] init];
        if (object && [object respondsToSelector:@selector(go:data:)]) {
            [object go:context data:data];
        }
    }
}

- (NSDictionary *)gotoMap {
    if (!_gotoMap) {
        _gotoMap = [NSDictionary dictionaryWithObjectsAndKeys:
                    @"GoToGoodDetail", @(ToGoodDetail),
                    @"GoToArticleDetail", @(ToArticleDetail),
                    @"GoToTopicDetail", @(ToTopicDetail),
                    @"GoToTribeHome",@(ToTribeHome),
                    @"GoToHisCenter",@(ToHisCenter),
                    nil];
    }
    return _gotoMap;
}

@end
